package org.sensation.server.operation.management;

import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;
import org.sensation.server.operation.request.OperationRequest;

public class ManagementOffice {
	private static Map<Integer, OperationRequest> operationRequestContext 
								= new ConcurrentHashMap<Integer, OperationRequest>();
	
	public static Integer registNewOperationRequest(OperationRequest operationRequest) throws NoSuchElementException, IllegalStateException, Exception {
		Integer seqID = WatingNumberMachine.getSeqID();
		operationRequest.setSeqID(seqID);
		operationRequestContext.put(seqID, operationRequest);
		return seqID;
	}

	
	public static OperationRequest getOperationRequest(Integer key){
		return operationRequestContext.get(key);
	}
	
	public static void remove(Integer seqID) throws Exception{
		returnSeqID(seqID);
		operationRequestContext.remove(seqID);
	}
	
	private static void returnSeqID(Integer seqID) throws Exception{
		WatingNumberMachine.returnSeqID(seqID);
	}
}
